﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test1
{
    class PrimeNum
    {
        static void Main(string[] args)
        {
            Console.Write("请输入一个数：");
            string a = Console.ReadLine();
            int num = int.Parse(a);
            GetFactor(num);
        }

        static void GetFactor(int num)
        {
            Console.Write(num);
            Console.Write("的所有素数因子为：");
            for (int i = 2; 2 * i <= num; ++i)
                if (num % i == 0 && IsPrime(i))
                    Console.Write("{0} ", i);
            if (IsPrime(num))
                Console.Write(num);
        }
        static bool IsPrime(int num)
        {
            if (num == 1)
                return false;
            else if (num == 2)
                return true;
            else
                for (int i = 2; i * i <= num; ++i)
                    if (num % i == 0)
                        return false;
            return true;
        }
    }
}
